package com.googlecode.bubbler.api;



import java.util.logging.Level;
import java.util.logging.Logger;

import edu.brandeis.cs.steele.exceptions.PronunciationNotFindException;
import edu.brandeis.cs.steele.exceptions.WordNotFindException;
import edu.brandeis.cs.steele.spider.WebSpider;
import edu.brandeis.cs.steele.util.BubblerLogger;
import edu.brandeis.cs.steele.wn.Pronunciation;


public class WordNetFasadeImpl implements WordNetFasade {
    static Logger logger = BubblerLogger.getLogger();
   // static Logger logger = Logger.getLogger(WordNetFasadeImpl.class.getName());
    @Override
    public WordDTO getWordDTO(String word) {
        LookApEngine lookApEngine = new LookApEngine(word);
        StringBuilder wordBuild = new StringBuilder();
        StringBuilder tmp;
        try {
            tmp = lookApEngine.getNounSentens();
            wordBuild.append("Noun:\n");
            wordBuild.append(tmp);
        } catch (Exception e) {           
        }
        try {
            tmp = lookApEngine.getVerbSentens();
            wordBuild.append("Verb:\n");
            wordBuild.append(tmp);
        } catch (WordNotFindException e) {
        }
        WordDTO wordDTO = new WordDTO();
        wordDTO.setSentens(wordBuild.toString());
        try {
            Pronunciation pr = new Pronunciation(lookApEngine.getWordIdx());
            wordDTO.setPronunciationExists(true);
            wordDTO.setPronunciation(pr);
        } catch (PronunciationNotFindException e) {
            wordDTO.setPronunciationExists(false);
            logger.log(Level.WARNING, e.getMessage());
        }
        return wordDTO;
    }
}
